import {createWebHistory, createRouter} from "vue-router"
import routes from "./routes"
import useTabsStore from "@/store/tabs"

let tab

const router = createRouter({
    history: createWebHistory(),
    routes,
})

router.beforeEach((to, from, next) => {
    const tabsStore = useTabsStore()
    if(to.path === '/login'){
        next()
    }else{
        if(tabsStore.tabs.length === 0){
            tabsStore.tabs.push({
                titel: '总览',
                path: '/totalview',
                isActive: false
            })
        }
    }
})

export default router